/*
* Copyright (c) Microsoft Corporation.  All Rights Reserved.
*
* Thunks for the mocking framework; sets context in Tls before jumping to the target shim
*/
#pragma once
#include "Mock10.h"

#pragma push_macro("SEALED")
#undef SEALED

#if _MSC_VER >= 1400
# define SEALED sealed
#else
# define SEALED
#endif

namespace Mock10 { namespace Private
{
    class MOCK10_API DetourThunk SEALED
    {
    public:
        DetourThunk(void* pShim, void* pTarget, void* pDetour);
        ~DetourThunk();

        void* GetAddress();

        static HRESULT __stdcall GetDetourTlsValue(intptr_t& value);
        static HRESULT __stdcall GetTargetTlsValue(intptr_t& value);
        static HRESULT __stdcall GetTargetClassTlsValue(intptr_t& value);
        static HRESULT __stdcall GetReturnAddressTlsValue(intptr_t& value);
        
        static void __stdcall DestroyThreadLocalThunkData();
        static void __stdcall DestroyAllThreadLocalThunkData();

    private:
        struct Impl;
        Impl* m_pImpl;
    };
} /* namespace Private */ } /* namespace Mock10 */

#pragma pop_macro("SEALED")